/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package control.khachhang;

import com.toedter.calendar.JDateChooser;
import java.util.Date;
import java.util.List;
import javax.swing.ButtonGroup;
import javax.swing.JRadioButton;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import model.dao.khachhang.KhachHangDAO;
import model.entity.KhachHang;

/**
 *
 * @author Admin
 */
public class KHSuaThongTin_Dialog_ctrl {

    
    public static final void suaThongTinKhachHang(JTable table, JTextField tfMaKH, JTextField tfHo,JTextField tfTen, ButtonGroup gGioiTinh,
                                            JTextField tfSDT,JDateChooser jdateNgaySinh,JTextField tfDiaChi, JTextArea taGhiChu){
        try {
        int maKh = Integer.parseInt(tfMaKH.getText());
        String ho = tfHo.getText();
        String ten = tfTen.getText();
      
        int a = gGioiTinh.getButtonCount();
        String gioiTinh = gGioiTinh.getSelection().getActionCommand();
        System.out.println(gioiTinh);

            
        String soDT = tfSDT.getText();
        Date ngaySinh = jdateNgaySinh.getDate();
        String diaChi = tfDiaChi.getText();
        String ghiChu = taGhiChu.getText();
        
        boolean kh = KhachHangDAO.suaKhachHangDialog(maKh, ho, ten, gioiTinh, ngaySinh, soDT, diaChi, ghiChu);
        List<KhachHang>list = KhachHangDAO.loaddAllKhachHang();
        KHMainPanel_ctrl.loadKhachHangLenTable(list, table);
        
         } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
